<?php
/**
 * Created by PhpStorm.
 * User: 35083
 * Date: 2019/7/5
 * Time: 10:34
 */

namespace app\admin\mapper;


class Txapply
{

    static private $instance = null;
    static public function getInstance()
    {
        //判断$instance是否是Uni的对象
        //没有则创建
        if (self::$instance == null) {
            self::$instance = new self();
        }
        return self::$instance;

    }
    public function txType($ty)
    {
        $string = "";
        if ($ty == '2') {
            $string = "支付宝";
        } else if ($ty == '1') {
            $string = "微信";
        }
        return $string;
    }

    /**
     * @param $list
     * @param int $color 是否返回样式 0不返回
     * @return mixed
     */
    public function listMapper($list,$color=0)
    {
        foreach ($list as $key => $val) {
            $list[$key] = $this->infoMapper($val,$color);
        }
        return $list;
    }

    public function statsMapper($ty)
    {
        $string = "";
        if ($ty == '0') {
            $string = "待审核";
        } else if ($ty == '1') {
            $string = "待打款";
        }else if ($ty == '2') {
            $string = "审核不通过";
        }else if ($ty == '3') {
            $string = "已打款";
        }else if ($ty == '4') {
            $string = "打款失败";
        }else if ($ty == '5') {
            $string = "已退回";
        } else if ($ty == '6') {
            $string = "打款中";
        }
        return $string;
    }

    public function infoMapper($info,$color=0)
    {
        $info['txTypeMapper'] = $this->txType($info['tx_type']);
        $info['statsMapper'] = $this->statsMapper($info['stats']);
        $info['ctimeMapper'] = formateDate($info['ctime']);
        $info['stimeMapper'] = formateDate($info['stime']);
        $info['ptimeMapper'] = formateDate($info['ptime']);
        return $info;
    }
}